
<!DOCTYPE html>
<html class="login-bg" xmlns:th="http://www.thymeleaf.org">
<head>
	<title>后台管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- bootstrap -->
    <link th:href="@{/css/bootstrap/bootstrap.css}" rel="stylesheet">
    <link th:href="@{/css/bootstrap/bootstrap-overrides.css}" type="text/css" rel="stylesheet">

    <!-- global styles -->
    <link rel="stylesheet" type="text/css" th:href="@{/css/compiled/layout.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/compiled/elements.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/compiled/icons.css}">

    <!-- libraries -->
    <link rel="stylesheet" type="text/css" th:href="@{/css/lib/font-awesome.css}">

    <!-- this page specific styles -->
    <link rel="stylesheet" th:href="@{/css/compiled/signin.css}" type="text/css" media="screen" />

    <!-- open sans font -->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>

    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>
<body>
    <div class="login-wrapper">
        <a >
            <img class="logo" src="img/logo-white.png">
        </a>

        <div class="box">
            <div class="content-wrap">
                <h6>登录</h6>
                <input class="form-control" type="text" placeholder="用户名" id="username">
                <input class="form-control" type="password" placeholder="密码" id="password">
                <p>验证码：<input type="text" name="vcode" id="vcode"/>
                    <img th:src="@{/getGifCode}" height="40px" width="60px" onclick="this.src=this.src+'?'"/></p>
                <span id="erro"></span>
                <a href="#" class="forgot">忘记密码?</a>
                <div class="remember">
                    <input id="rememberMe" type="checkbox">
                    <label for="rememberMe">记住我</label>
                </div>
                <button class="btn-glow primary login" id="ajaxLogin">登录</button>
            </div>
        </div>

        <div class="no-account">
            <p>还没账号?</p>
            <a th:href="@{/signup}">注册</a>
        </div>
    </div>

	<!-- scripts -->
    <script th:src="@{/js/jquery-1.11.3.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <script th:src="@{/js/theme.js}"></script>

    <script>
        function random(tmp){
            alert("1")
            tmp.src="/getGifCode";
        }

        $("#ajaxLogin").click(function () {
            var username = $("#username").val();
            var password = $("#password").val();
            var vcode = $("#vcode").val();
            var rememberMe =$('#rememberMe').is(':checked');
            $.ajax({
                url:"/ajaxLogin",
                type:"post",
                data:{
                    "username": username,
                    "password": password,
                    "vcode" : vcode,
                    "rememberMe" : rememberMe
                },
                dataType:"json",
                beforeSend:function () {
                    $("#ajaxLogin").attr('disabled','disabled');
                    $("#ajaxLogin").text("登录中...");
                },
                success:function(result){
                    if (result.status == 200) {
                        location.href = "/index";
                    } else {
                        $("#erro").html(result.message);
                        //让提交按钮重新有效
                        $("#ajaxLogin").text("登录");
                        $("#ajaxLogin").removeAttr('disabled');
                    }
                },
                error:function(){
                    toastr.error('注册用户失败！');
                }
//                ,
//                complete: function() {
//                    //让提交按钮重新有效
//                    $("#ajaxLogin").text("登录");
//                    $("#ajaxLogin").removeAttr('disabled');
//                },

            });

        });
    </script>
</body>
</html>